package me.softwareengineer.guice.rendering.domain;

import me.softwareengineer.guice.rendering.listener.Listener;
import me.softwareengineer.guice.rendering.listener.OnRawEvent;

/**
 * Represents some raw content that shouldn't be parsed or modified and that
 * should be injected as is in any output. The content depends on a syntax and
 * listeners decide if they can handle that syntax or not. For example if it's
 * in "xhtml/1.0" syntax then the XHTML Renderer can insert it directly in the
 * XHTML output.
 * 
 * @author yadtahir
 * 
 */
public class RawElement extends Element {
	/**
	 * @see #getRawContent()
	 */
	private final String rawContent;

	/**
	 * The syntax of the raw data
	 */
	private final Syntax syntax;

	/**
	 * Constructs a raw element
	 * 
	 * @param rawContent
	 *            the content of the element
	 * @param syntax
	 *            the syntax of the content
	 * @see Syntax
	 */
	public RawElement(String rawContent, Syntax syntax) {

		this.rawContent = rawContent;

		this.syntax = syntax;

	}

	/**
	 * 
	 * @return the content of the element
	 * <p>
	 * This property is immutable and thread-safe
	 * </p>
	 */
	public String getRawContent() {
		
			return rawContent;
	

	}

	/**
	 * 
	 * @return the syntax of the content
	 * @see Syntax
	 * <p>
	 * This property is immutable and thread-safe
	 * </p>
	 */
	public Syntax getSyntax() {
		
			return this.syntax;
		

	}

	

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void render(Listener l) {
		OnRawEvent e = new OnRawEvent(getSyntax(), getRawContent());
		l.onEvent(e);
	}

	
}
